package com.guigu.www.controller;


import com.guigu.www.common.PageVo;
import com.guigu.www.pojo.Dept;
import com.guigu.www.pojo.Employee;
import com.guigu.www.service.DeptService;
import com.guigu.www.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tj
 * @since 2021-03-17
 */
@RestController
public class EmployeeController {
    @Autowired
    EmployeeService employeeService;
    @Autowired
    private DeptService deptService;

    @PostMapping("emp")
    public PageVo<Employee> findEmpList(@RequestBody Map<String,String> map) {
        return employeeService.findList(map);
    }

//    @PostMapping("emp")
//        public PageVo<Employee> findEmpList(@RequestBody Map<String,String> map,Employee employee) {
//            return employeeService.findList(map,employee);
//        }
    @GetMapping("queryById")
    public Employee queryById(int empno){
        return employeeService.queryById(empno);
    }
    @GetMapping("queryDept")
    public List<Dept> queryDept(){
        return deptService.queryDept();
    }
    @GetMapping("addEmp")
    public int addEmp(Employee employee){
        return employeeService.addEmp(employee);
    }
    @GetMapping("updEmp")
    public int updEmp(Employee employee){
        return employeeService.updEmp(employee);
    }
    @GetMapping("delEmp")
    public int delEmp(int empno){
        return employeeService.delEmp(empno);
    }
}

